package main.kotlin

class QuickSort {

    fun main(){

    }

    fun quickSort(arr:Array<Int>):Array<Int>{
        val baseValue = arr[0]
        var i = 0
        var j = arr.size-1
        while (i<j){
            if (arr[++i]<baseValue){
                continue
            }
            while (arr[j]>baseValue){
                j--
            }
            if (i<j){
                var temp = arr[i]
                arr[i] = arr[j]
                arr[j] = temp
            }
        }



        return arr
    }

}